package com.wang.pool;


import com.wang.thread.ThreadRunnable;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool {
    static volatile int count = 0;

    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3,20,10,
                TimeUnit.SECONDS,new ArrayBlockingQueue<>(10),new ThreadPoolExecutor.CallerRunsPolicy());



        for (int i = 0;i<100;i++){
            poolExecutor.execute(new ThreadRunnable(count));
            count++;

        }
        System.out.println("主线程执行完毕！");
    }
}
